//
//  ProductManagerViewController.m
//  LazyCat
//
//  Created by jike on 16/4/28.
//  Copyright (c) 2016年 zhanshu. All rights reserved.
//

#import "ProductManagerViewController.h"
#import "GoodsManagerViewController.h"//商品管理
#import "ClassifyManageViewController.h"//分类
#import "ProductManagerVC.h"//产品库
#import "MallCategoryVC.h"
#import "AddProductViewController.h" //添加商品
#import "MainManagerButton.h"
#import "SearchViewController.h"
@interface ProductManagerViewController ()

@end

@implementation ProductManagerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createUI];
}
- (void)createUI {
    [self initNav:@"商品管理" doBack:YES];
    //背景图
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, 74, ScreenWidth, ScreenHeight - 74)];
    backView.backgroundColor = BackColor;
    [self.view addSubview:backView];
    
    //分类
    NSArray *imageNameArr = @[@"sp_tj_icon",@"sp_gl_icon",@"sp_rm_icon",@"sp_ku_icon",@"sp_ss_icon"];
    
    NSArray *titleArr = @[@"添加商品",@"商品管理",@"热门商品",@"商品库",@"商品搜索"];
    
    CGFloat radio = 220 / 250.0;
    CGFloat width = (ScreenWidth - 2) / 3.0;
    CGFloat height = width * radio;
    
    
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 3; j++) {
            if (!(i == 1 && j == 2)) {
                int index = i * 3 + j;
                MainManagerButton *btn = [[MainManagerButton alloc] init];
                btn.backgroundColor = [UIColor whiteColor];
                btn.frame = CGRectMake(1 * j + width * j, height * i + 1 *i, width, height);
                [btn setTitle:titleArr[index] forState:UIControlStateNormal];
                [btn setImage:[UIImage imageNamed:imageNameArr[index]] forState:UIControlStateNormal];
                NSLog(@"%d",index );
                [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
                btn.tag = 10 + index;//10,11,12,13,14
                btn.adjustsImageWhenHighlighted = NO;
                [backView addSubview:btn];
            }
        }
    }
}
- (void)btnClick:(UIButton *)sender {
    if (sender.tag == 10) {//添加商品
        AddProductViewController *addVC = [[AddProductViewController alloc]init];
        addVC.addVCStyle = LCProductStyleAdd;
        [self.navigationController pushViewController:addVC animated:YES];
    }else if (sender.tag == 11){//商品管理
//        GoodsManagerViewController *goodsManagerVC = [[GoodsManagerViewController alloc]init];
        ProductManagerVC *productManagerVC = [[ProductManagerVC alloc]init];
        productManagerVC.isHotVC = @"";
        [self.navigationController pushViewController:productManagerVC animated:YES];
        
    }else if (sender.tag == 12){//热门商品
        ProductManagerVC *productManagerVC = [[ProductManagerVC alloc]init];
        productManagerVC.isHotVC = @"1";
        [self.navigationController pushViewController:productManagerVC animated:YES];
    }else if (sender.tag == 13){//商品库
        MallCategoryVC *productsLib = [[MallCategoryVC alloc]init];
        [self.navigationController pushViewController:productsLib animated:YES];
    }else if (sender.tag == 14){// 商品搜索
        SearchViewController *searchVC = [[SearchViewController alloc]init];
        searchVC.searchType = TypeProductsManager;
        searchVC.isHotVC = @"";
        [self.navigationController pushViewController:searchVC animated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
